package tsg.component;

import tsg.graphic.Color;
import tsg.laf.LookAndFeel;
import tsg.laf.LookAndFeelManager;

public class SquareBorder extends Border
{
	public SquareBorder(Component component, int lineWidth, Color color)
	{
		_component = component;
		_lineWidth = lineWidth;
		_color     = color;
		this.setUI(LookAndFeelManager.getComponentUI(LookAndFeel.KEY_BORDER_SQUARE_COMPONENTUI));
	}
	
	public void setParentComponent(Component component)
	{
		_component = component;
	}
	
	public void setLineWidth(int lineWidth)
	{
		_lineWidth = lineWidth;
	}
	
	public void setColor(Color color)
	{
		_color = color;
	}

	public boolean[][] getBoundingMap()
	{
		int width  = _component.getSize().getWidth();
		int height = _component.getSize().getHeight();
		
		boolean[][] boundingMap = new boolean[height][width];
		
		for(int j=0; j<boundingMap.length; j++)
		{
			for(int i=0; i<boundingMap[j].length; i++)
			{
				if( j<_lineWidth || j >= width  - _lineWidth ||
					i<_lineWidth || i >= height - _lineWidth )
				{
					boundingMap[j][i] = true;
				}
				else
				{
					boundingMap[j][i] = false;
				}
			}
		}
		
		return boundingMap;
	}
	
	/**
	 * 
	 * @return
	 */
	public Color getColor()
	{
		return _color;
	}
	
	/**
	 * 
	 * @return
	 */
	public int getLineWidth()
	{
		return _lineWidth;
	}
	
	private Component _component = null;
	private int       _lineWidth = 0;
	private Color     _color     = null;
}
